#!/srv/newsblur/venv/newsblur3/bin/python

from vendor.munin.ddwrt import DDWrtPlugin


class DDWrtWirelessSignalPlugin(DDWrtPlugin):
    title = "Wireless signal"
    args = "--base 1000 -l 0"
    vlabel = "units"
    info = "signal quality"
    fields = (
        ('signal', dict(
            label = "signal",
            info = "signal",
            type = "GAUGE",
        )),
        ('noise', dict(
            label = "noise",
            info = "noise",
            type = "GAUGE",
        )),
    )

    def execute(self):
        info = self.get_info()
        active = info['active_wireless']
        signal, noise = active.split(',')[1:3]
        return dict(
            signal = signal[1:-1],
            noise = noise[1:-1],
        )

if __name__ == "__main__":
    DDWrtWirelessSignalPlugin().run()
